package com.bdjk.bdmw.InfoGath.ws.position.service.impl;


import io.netty.channel.Channel;

import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.stereotype.Component;

import com.bdjk.bdmw.InfoGath.common.constants.ChannelMap;
import com.bdjk.bdmw.InfoGath.communication.server.tcp.netty.SendClientCommand;
import com.bdjk.bdmw.InfoGath.ws.position.service.SetNumberWS;
//@Component("positionWS")
public class SetNumberWSImpl implements SetNumberWS {

	@GET
	@Path("/setSOS/{ter_Ident}/{index}/{number}")
	@Produces(MediaType.APPLICATION_JSON)
	public String setSOS(@PathParam("ter_Ident")String terIdent,@PathParam("index")int index,@PathParam("number")String telNum) {
		// TODO Auto-generated method stub
		String commType="3G";
		StringBuffer sb=new StringBuffer();
		sb.append("["+commType+"*"+terIdent+"*0010*SOS"+index+","+telNum+"]");
		SendClientCommand sendClientCommand=new SendClientCommand();
		int result=sendClientCommand.send(terIdent, sb.toString());
		if(-1==result){
			return("no such terminal!");
		}else{
			return("success!");
		}
	}

	@GET
	@Path("/setSOS/{ter_Ident}/{number1}/{number2}/{number3}")
	@Produces(MediaType.APPLICATION_JSON)
	public String setSOS(@PathParam("ter_Ident")String terIdent,@PathParam("number1")String telNum1,@PathParam("number2")String telNum2,@PathParam("number3")String telNum3) {
		// TODO Auto-generated method stub
		String commType="3G";
		StringBuffer sb=new StringBuffer();
		sb.append("["+commType+"*"+terIdent+"*0027*SOS,"+telNum1+","+telNum2+","+telNum3+"]");
		SendClientCommand sendClientCommand=new SendClientCommand();
		int result=sendClientCommand.send(terIdent, sb.toString());
		if(-1==result){
			return("no such terminal!");
		}else{
			return("success!");
		}
	}
	
	@GET
	@Path("/setCenter/{ter_Ident}/{number}")
	@Produces(MediaType.APPLICATION_JSON)
	public String setCenter(@PathParam("ter_Ident")String terIdent,@PathParam("number")String telNum) {
		// TODO Auto-generated method stub
		String commType="3G";
		StringBuffer sb=new StringBuffer();
		sb.append("["+commType+"*"+terIdent+"*0012*CENTER,"+telNum+"]");
		SendClientCommand sendClientCommand=new SendClientCommand();
		int result=sendClientCommand.send(terIdent, sb.toString());
		if(-1==result){
			return("no such terminal!");
		}else{
			return("success!");
		}
	}
	
	@GET
	@Path("/setCenter/{slave}/{ter_Ident}/{number}")
	@Produces(MediaType.APPLICATION_JSON)
	public String setCenter(@PathParam("ter_Ident")String terIdent,@PathParam("number")String telNum,@PathParam("slave")String slave) {
		// TODO Auto-generated method stub
		String commType="3G";
		StringBuffer sb=new StringBuffer();
		sb.append("["+commType+"*"+terIdent+"*0011*"+slave+","+telNum+"]");
		SendClientCommand sendClientCommand=new SendClientCommand();
		int result=sendClientCommand.send(terIdent, sb.toString());
		if(-1==result){
			return("no such terminal!");
		}else{
			return("success!");
		}
	}
	
	@GET
	@Path("/setWhiteNum/{ter_Ident}/{number}")
	@Produces(MediaType.APPLICATION_JSON)
	public String setWhiteNum(@PathParam("ter_Ident")String terIdent,@PathParam("number")String telNum) {
		// TODO Auto-generated method stub
		String commType="3G";
		StringBuffer sb=new StringBuffer();
		sb.append("["+commType+"*"+terIdent+"*0016*WHITELIST1,"+telNum+"]");
		SendClientCommand sendClientCommand=new SendClientCommand();
		int result=sendClientCommand.send(terIdent, sb.toString());
		if(-1==result){
			return("no such terminal!");
		}else{
			return("success!");
		}
	}
	
	
	
}
